<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>打印</title>
	<style>
		body{
			margin: 0;
		}
	</style>
</head>

<body>
	<script>
		var backValue = 0
		function GetRequest() {
			var url = location.search; //获取url中"?"符后的字串
			var theRequest = new Object();
			if (url.indexOf("?") != -1) {
			var str = url.substr(1);
				strs = str.split("&");
				for(var i = 0; i < strs.length; i ++) {
					theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
				}
			}
			return theRequest;
		}
		let paramsObj = GetRequest()
		let adminToken = sessionStorage.getItem('adminToken')
		let xhr = new XMLHttpRequest();
        xhr.open("post","/newApi/ad/pkInfo/getPrintTemplate",true);
        xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xhr.setRequestHeader("Authorization",adminToken);
		xhr.send("idStr="+paramsObj.id+"&oldType="+paramsObj.oldType)
		xhr.onload = function(e) {
			if(this.status == 200){
				let result = JSON.parse(xhr.response)
				console.log(xhr.response)
				let html = ''
				result.result[0].printTemplate
				result.result.forEach((res,index) => {
					let length = result.result.length
					if(index < length - 1){
						html +='<div style=height:480px;position:relative;>'+res.printTemplate+'</div><div style="page-break-before: always"></div>'
					}else{
						html += '<div style=height:480px;position:relative;>'+res.printTemplate+'</div>'
					}
				});
				document.write(html)
				backValue = 1
			}
		}
	</script>
</body>

</html>
